package com.cxx.purchasecharge.core.model.persistence.auditlog;

import java.util.Date;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import com.cxx.purchasecharge.core.model.BaseModel;
import com.cxx.purchasecharge.core.model.LogTypeCode;

/**
 * 操作日志主表
 * 
 * @author xiang
 * 
 */
@Entity
@Table (name = "pc_log")
public class Log extends BaseModel
{
    private static final long serialVersionUID = 1L;

    private long id;
    /**
     * 操作类型
     */
    private LogTypeCode type = LogTypeCode.INSERT;
    private String userId;
    private String tableId;
    private String tableName;
    private Date date;
    private String comment;

    private List <LogContent> contents;

    @Id
    @GeneratedValue (strategy = GenerationType.AUTO)
    public long getId ()
    {
        return id;
    }

    public void setId (long id)
    {
        this.id = id;
    }

    @Column (nullable = false)
    public LogTypeCode getType ()
    {
        return type;
    }

    public void setType (LogTypeCode type)
    {
        this.type = type;
    }

    @Column (nullable = false)
    public String getUserId ()
    {
        return userId;
    }

    public void setUserId (String userId)
    {
        this.userId = userId;
    }

    public String getTableId ()
    {
        return tableId;
    }

    public void setTableId (String tableId)
    {
        this.tableId = tableId;
    }

    @Column (nullable = false)
    public String getTableName ()
    {
        return tableName;
    }

    public void setTableName (String tableName)
    {
        this.tableName = tableName;
    }

    @Column (nullable = false)
    public Date getDate ()
    {
        return date;
    }

    public void setDate (Date date)
    {
        this.date = date;
    }

    public String getComment ()
    {
        return comment;
    }

    public void setComment (String comment)
    {
        this.comment = comment;
    }

    @OneToMany (cascade =
    { CascadeType.ALL }, mappedBy = "log")
    public List <LogContent> getContents ()
    {
        return contents;
    }

    public void setContents (List <LogContent> contents)
    {
        this.contents = contents;
    }
}
